using NUnit.Framework;

namespace ValidationFramework.Tests
{
    [TestFixture]
    public class RangeStringRuleAttributeTest
    {
        const string expectedMinimum = "a";
        const string expectedMaximum = "c";

        [Test]
        public void CheckValues()
        {
            var ruleAttribute = new RangeStringRuleAttribute(expectedMinimum, expectedMaximum);
            Assert.AreEqual(expectedMinimum, ruleAttribute.Minimum);
            Assert.AreEqual(expectedMaximum, ruleAttribute.Maximum);

            var propertyRule = (RangeStringRule)ruleAttribute.CreateInstance(new MockPropertyDescriptor<string>("foo"));
            var parameterRule = (RangeStringRule)ruleAttribute.CreateInstance(new MockParameterDescriptor<string>("foo"));
            var fieldRule = (RangeStringRule)ruleAttribute.CreateInstance(new MockFieldDescriptor<string>("foo"));

            Assert.AreEqual(expectedMinimum, parameterRule.Minimum);
            Assert.AreEqual(expectedMaximum, propertyRule.Maximum);

            Assert.AreEqual(expectedMinimum, propertyRule.Minimum);
            Assert.AreEqual(expectedMaximum, fieldRule.Maximum);

            Assert.AreEqual(expectedMinimum, propertyRule.Minimum);
            Assert.AreEqual(expectedMaximum, fieldRule.Maximum);

        }


        [Test]
        public void CallAttributeTester()
        {
            AttributeTester.CheckDefaultValues<string>(new RangeStringRuleAttribute(expectedMinimum, expectedMaximum), true, true, true);
            AttributeTester.CheckNonDefaultValues<string>(new RangeStringRuleAttribute(expectedMinimum, expectedMaximum), true, true, true);
        }


    }
}